'''
快捷添加用户类页面
'''
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from selenium.webdriver.support.select import Select

class AddUserKuaijiePage(BasePage):

    # 定位器
    tianjiayonghu_yonghuming_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/form/table/tbody/tr[1]/td[2]/input')
    tianjiayonghu_mima_locator = (By.ID, 'password')
    tianjiayonghu_yonghuleibie_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/form/table/tbody/tr[3]/td[2]/select')
    tianjiayonghu_bumen_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/form/table/tbody/tr[4]/td[2]/select')
    tianjiayonghu_gangwei_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/form/table/tbody/tr[5]/td[2]/select')

    tianjiayonghu_tianjia_btn_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/form/table/tbody/tr[6]/td[2]/input[1]')
    tianjiayonghu_quxiao_btn_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/div/div[2]/form/table/tbody/tr[6]/td[2]/input[3]')

    yxtj_duanyan_text_locator = (By.CSS_SELECTOR,'#add > span')
    tjyh_duanyan_mimaweikong_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/div[1]')
    tjyh_duanyan_tjcg_locator=(By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    # 输入用户名
    def tjyh_kj_yhm(self, name):
        self.driver.find_element(*self.tianjiayonghu_yonghuming_locator).send_keys(name)

    # 输入密码
    def tjyh_kj_mm(self, mima):
        self.driver.find_element(*self.tianjiayonghu_mima_locator).send_keys(mima)

    # 选择用户类别
    def tjyh_kj_yhlb(self):
        yhlb = self.driver.find_element(*self.tianjiayonghu_yonghuleibie_locator)
        Select(yhlb).select_by_index(1)

    # 选择部门
    def tjyh_kj_bm(self):
        bumen = self.driver.find_element(*self.tianjiayonghu_bumen_locator)
        Select(bumen).select_by_index(1)

    # 选择岗位
    def tjyh_kj_gw(self):
        gangwei = self.driver.find_element(*self.tianjiayonghu_gangwei_locator)
        Select(gangwei).select_by_index(0)

        # 点击保存
    def tjyh_kj_baocun(self):
        self.driver.find_element(*self.tianjiayonghu_tianjia_btn_locator).click()

        # 点击保存并新建
    # def tjyh_kj_baocunbingxinjian(self):
    #     self.driver.find_element(*self.tianjiayonghu_tianjia_btn_locator).click()

        # 点击取消
    def tjyh_kj_quxiao(self):
        self.driver.find_element(*self.tianjiayonghu_quxiao_btn_locator).click()

    # 断言跳转邮箱添加
    def tjyh_dy_youxiangtiaozhuan(self):
        wb=self.driver.find_element(*self.yxtj_duanyan_text_locator)
        return wb.text
    # 断言密码为空
    def tjyh_dy_mimaweikong(self):
        wb=self.driver.find_element(*self.tjyh_duanyan_mimaweikong_locator)
        return wb.text
    # 断言地址
    def get_current_url(self):
        return self.driver.current_url

    # 断言添加成功
    def tjyh_yd_cg(self):
        wb=self.driver.find_element(*self.tjyh_duanyan_tjcg_locator)
        return wb.text